<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Ajax抓取数据API</title>
</head>

<body>
    <div id="dog"></div>
    <a href="javascript:void(0)" id="wang">获取数据</a>
    <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <script>
        var key = "66e9b94c0b5df731f209f6da2be830e7";
        var num = 10;
        $("#wang").click(function() {
            $.ajax({
                url: "http://api.tianapi.com/meinv/",
                data: {
                    key: key,
                    num: num
                },
                success: function(data) {
                    data = data.newslist;
                    // console.log(data);
                    for (var i = data.length - 1; i >= 0; i--) {
                        var d = "<div class='" + "wrap'><img src='" + data[i].picUrl + "'></div>'";
                        $("#dog").append(d);
                    }
                }
            })
        })
    </script>
</body>

</html>